#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 3010, mod = 2333;
int a[N][N];
int dp[N][N];
int n, m;
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    dp[n][0] = 1;
    for (int i = n; i >= 1; i--)
    {
        for (int j = 1; j <= m; j++)
        {
            if (a[i][j] == 0)
                dp[i][j] = (dp[i][j - 1] + dp[i + 1][j]) % mod;
            else
                dp[i][j] = 0;
        }
    }
    printf("%d", dp[1][m]);
    return 0;
}